/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nl.ivarclemens.gpstrack.track;

/**
 *
 * @author ivar
 */
public abstract class Track {

    // Cached boundaries
    double minLat;
    double minLon;
    double maxLat;
    double maxLon;


    /**
     * Return boundaries
     */
    public double getMinLon()
    {
        return minLon;
    }

    public double getMinLat()
    {
        return minLat;
    }

    public double getMaxLon()
    {
        return maxLon;
    }

    public double getMaxLat()
    {
        return maxLat;
    }

    public abstract void remapTrack(int froPtr, int toPtr);
    public abstract void clear();

    public void appendPosition(long time, double lat, double lon)
    {
        if(this.numPoints() == 0) {
            minLat = lat;
            minLon = lon;
        } else {
            if(minLat > lat) minLat = lat;
            if(minLon > lon) minLon = lon;
            if(maxLat < lat) maxLat = lat;
            if(maxLon < lon) maxLon = lon;
        }
    }

    public abstract int numPoints();
    public abstract long getTime(int idx);
    public abstract double getLat(int idx);
    public abstract double getLon(int idx);
    public abstract double getDistance(int idx);

}
